﻿// See https://aka.ms/new-console-template for more information

namespace AttributeDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Test();
            Console.ReadKey();
        }
        [CatchException]
        static void Test()
        {
            var a = "hello world";
            var b = Convert.ToInt32(a);
        }
        public void TestNew()
        {
            var a  = typeof(Program);

        }
    }

    [AttributeUsage(AttributeTargets.Method,AllowMultiple =false)]
    class CatchExceptionAttribute : Attribute
    {
        //public void OnException(ExceptionContext context)
        //{
        //    //获取异常信息，入库保存
        //    var error = context.Exception;
        //    var message = error.Message;//错误信息
        //    Console.WriteLine(message);
        //}
    }
}

